<template>
  <div class="app-container">
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
         <el-row>
            <el-col :span="6">
              <el-form-item label="企业名称" prop="tenantName">
                <el-input v-model="form.tenantName" maxlength="50" placeholder="请输入企业名称" />
              </el-form-item>
            </el-col>
         </el-row>
           <el-row>
            <el-col :span="6">
              <el-form-item label="企业编号" prop="tenantCode">
                <el-input v-model="form.tenantCode" maxlength="50" placeholder="请输入企业编号" :disabled="edit"/>
              </el-form-item>
            </el-col>
         </el-row>
          <el-row>
              <el-col :span="6">
                  <el-form-item label="企业简称" prop="abbreviation">
                    <el-input  v-model="form.abbreviation" maxlength="50" placeholder="企业简称" />
                  </el-form-item>
              </el-col>
          </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
      </div>
  </div>
</template>

<script>
import { insertTenant } from "@/api/system/tenant";
export default {
  name: "Tenant",
  data() {
    return {
      // 遮罩层
      loading: true,
      showConfig: false,
      configTenantId:-1,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 企业管理表格数据
      tenantList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: true,
      edit:false,
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        tenantName: [
          { required: true, message: "企业名称不能为空", trigger: "blur" }
        ],
        tenantCode: [
          { required: true, message: "企业编号不能为空", trigger: "blur" }
        ],
        abbreviation: [
          { required: true, message: "企业简称不能为空", trigger: "blur" }
        ],
      }
    };
  },
  methods: {
    // 表单重置
    reset() {
      this.form = {
        tenantName: null,
        tenantCode: null,
        abbreviation: null
      };
      this.resetForm("form");
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          insertTenant(this.form).then(response => {
            this.$modal.msgSuccess("新增成功");
            this.resetForm("form");
          });
        }
      });
    }
  }
};
</script>
